﻿<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
  <CustomAction
     Id="SPPropertyBagManagement.CustomActions.WebAppAdmin"
     Location="CommandUI.Ribbon"
     RequiredAdmin="Farm"
     Title="Property bag management"
     Sequence="100">
    <CommandUIExtension>
      <CommandUIDefinitions>
        <CommandUIDefinition
          Location="Ribbon.WebApp.Manage.Controls._children">
          <Button Id="SPPropertyBagManagement.CustomActions.WebAppAdmin.Button"
            Command="EA6A1261-4967-4372-84C2-CD5DCE1B46AF"
            Sequence ="100"
            LabelText="Property bag management"
            Image16by16="/_layouts/images/SPPropertyBagManagement/propsIcon.gif"
            ToolTipTitle="Property bag management"
            ToolTipDescription="Manage web application properties"
            TemplateAlias="o2" />
        </CommandUIDefinition>
      </CommandUIDefinitions>
      <CommandUIHandlers>
        <CommandUIHandler
          Command="EA6A1261-4967-4372-84C2-CD5DCE1B46AF"
          EnabledScript="javascript:(function (){return SP.UI.Admin.WebApplicationPageComponent.isEnabled(0);})();"
          CommandAction="javascript: 
function navigateMe(){
var target = '/_layouts/SPPropertyBagManagement/PropertiesEdit.aspx?Scope=WebApplication&amp;Id=';          
var webApp = SP.UI.Admin.WebApplicationPageComponent.$0_1;
var finalTarget;

if (null === webApp) {
    return;
}

finalTarget = String.format('{0}{1}', target, webApp.getAttribute('Id'));

window.location.href = finalTarget;
};
var res = navigateMe();
                        "
          />
      </CommandUIHandlers>
    </CommandUIExtension>
  </CustomAction>
</Elements>
